package com.eastfair.home.controller;

/**
 * @Author suolong
 * @Date 2022/8/8 20:58
 */

import com.eastfair.annotation.annotation.log.SysLog;
import com.eastfair.core.base.R;
import com.eastfair.home.service.SpecsService;
import com.eastfair.venueservice.dto.ServiceSpecsDTO;
import com.eastfair.venueservice.vo.ServiceSpecsVO;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * 服务分类规格
 * </p>
 *
 * @author lyw
 * @date 2022-08-08
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/specs")
@Api(value = "specs", tags = "服务分类规格")
public class SpecsController {
    @Autowired
    private SpecsService specsService;


    /**
     * 根据服务分类id查询规格列表
     * @param categoryId
     * @return
     */
    @GetMapping(value = "/getSpecsListByCategoryId/{categoryId}")
   public R<List<ServiceSpecsVO>> getSpecsListByCategoryId(@PathVariable("categoryId") Long categoryId){
      List<ServiceSpecsVO> serviceSpecsVOList=  specsService.getSpecsListByCategoryId(categoryId);
      return R.success(serviceSpecsVOList);
    }


    /**
     * 保存服务规格
     * @param serviceSpecsDTO
     * @return
     */
    @SysLog("添加服务规格")
    @PostMapping(value = "/saveSpecsInfo")
    public R<Boolean> saveSpecsInfo(@RequestBody ServiceSpecsDTO serviceSpecsDTO){
      return R.success(specsService.saveSpecsInfo(serviceSpecsDTO));
    }


    /**
     * 删除规格
     * @param id
     * @return
     */
    @SysLog("删除服务规格")
    @GetMapping(value = "/delSpecsById/{id}")
    public R<Boolean> delSpecsById(@PathVariable("id") Long id){
        return R.success(specsService.delSpecsById(id));
    }



}
